package tragame.game;

import java.rmi.RemoteException;

import tragame.game.Resource.ResourceType;
import tragame.interfaces.IBuildingStorage;

public class BuildingStorage extends Building implements IBuildingStorage{

	private static final long serialVersionUID = 1L;
	
	private ResourceType resource;
	private int amount;
	
	public enum BuildingStorageType {
		Entrepot, Silo;
		public BuildingType getBuildingType() {
			switch(this) {
				case Entrepot:
					return BuildingType.Entrepot;
				default:
					return BuildingType.Silo;
			}
		}
		public ResourceType getResourceType() {
			switch(this) {
				case Entrepot:
					return ResourceType.bois;
				default:
					return ResourceType.nourriture;
				
			}
		}
	}		
	
	public BuildingStorage(BuildingStorageType type) throws RemoteException {
		super(type.getBuildingType());
		initialize(type);
	}
	
	private void initialize(BuildingStorageType type){
		this.resource = type.getResourceType();
	}
	
	public ResourceType getRessource(){
		return this.resource;
	}
	
	public int getAmount(){
		return this.amount;
	}
	
	public void createBuilding(){
		this.amount += 1000;
	}
	
	public void upgradeBuilding(){
		this.amount *= 2;
	}
}
